/** @format */

import React from 'react';
import Header from './header';
import Menu from './menu';
import Content from './content';
import {contentWrap} from './index.styl';
import {withRouter} from 'react-router-dom';

interface ILocation {
  [propName: string]: any;
}

interface IProps {
  location: ILocation;
  history: ILocation;
}

class AdminContent extends React.Component<IProps> {
  constructor(props: IProps) {
    super(props);
  }

  componentDidMount() {
    !localStorage.getItem('token') ? this.props.history.push('/login') : '';
  }

  render(): JSX.Element {
    return (
      <>
        <Header />
        <div>
          <Menu />
          <div className={contentWrap}>
            <Content />
            <footer>Copyright © {`${new Date().getFullYear()} ${window.location.host}`}</footer>
          </div>
        </div>
      </>
    );
  }
}

export default withRouter(AdminContent as any);
